function aesDecrypt(Str, sign) {
	var key = sign.substring(0, 8) + sign.substring(16, 24);
	var iv = sign.substring(8, 16) + sign.substring(24, 32);


	var decrypted = CryptoJS.AES.decrypt(decodeURIComponent(Str), CryptoJS.enc.Utf8.parse(key), {
		iv: CryptoJS.enc.Utf8.parse(iv),
		mode: CryptoJS.mode.CBC,
		padding: CryptoJS.pad.ZeroPadding
	});

	var plaintext = decrypted.toString(CryptoJS.enc.Utf8); //WordArray对象转utf8字符串

	if (plaintext.substring(0, 1) == '{') {
		return JSON.parse(plaintext.substring(0, (plaintext.lastIndexOf('}') + 1)));
	} else {
		return JSON.parse(plaintext.substring(0, (plaintext.lastIndexOf(']') + 1)));
	}
}

function getTimeString(seconds) {
    var hours = Math.floor(seconds / 3600);
    var minutes = Math.floor((seconds % 3600) / 60);
    var seconds = Math.floor((seconds % 3600) % 60);
    
    return (hours.toString().padStart(2, '0') < 0 ? 0 :hours.toString().padStart(2, '0')) + ' 小时 ' + (minutes.toString().padStart(2, '0') < 0 ? 0 : minutes.toString().padStart(2, '0')) + ' 分 ' + (seconds.toString().padStart(2, '0')< 0 ? 0 : seconds.toString().padStart(2, '0')) +' 秒';
  }


/**
 * 时间戳转换为时间格式
 * @param {*} timestamp 时间戳
 * @param {*} format  时间格式
 */
function format(timestamp,format="Y-m-d H:i:s") {
    if(!Number(timestamp) ) {
        return '--';
    }
    if(String(timestamp).length === 10) {
        timestamp *= 1000;
    }
    var date = new Date(timestamp);
    var y = date.getFullYear();
    var m =(date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1);
    var d = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate());
    var h =  (date.getHours() < 10 ? "0" + date.getHours() : date.getHours());
    var i = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes());
    var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();

    var ts = format.toLowerCase();
    ts = ts.replace('y',y);
    ts = ts.replace('m',m);
    ts = ts.replace('d',d);
    ts = ts.replace('h',h);
    ts = ts.replace('i',i);
    ts = ts.replace('s',s);
    return ts;
}

async function fileParse(file, type = "base64") {
    return new Promise(resolve => {
        let fileRead = new FileReader();
        if (type === "base64") {
            fileRead.readAsDataURL(file);
        } else if (type === "buffer") {
            fileRead.readAsArrayBuffer(file);
        }
        fileRead.onload = (ev) => {
            resolve(ev.target.result);
        };
    });
}


/**
 * 首字母大写
 * @param {*} name 
 */
function capitalized(name) {
    const capitalizedFirst = name[0].toUpperCase();
    const rest = name.slice(1);
    return capitalizedFirst + rest;
}

var TagLunarCal=class{constructor(a,n,e,t,l,r,u,o,s,g,C,h,i,L,w,T,c){this.BaseDays=a,this.Intercalation=n,this.BaseWeekday=e,this.BaseKanChih=t,this.MonthDays=[l,r,u,o,s,g,C,h,i,L,w,T,c]}};new Vue({el:"#app",data:()=>({FIRSTYEAR:1998,LASTYEAR:2032,solarYear:(new Date).getFullYear(),solarMonth:(new Date).getMonth()+1,solarDate:(new Date).getDate(),weekdayString:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"][(new Date).getDay()],lunarMonth:"",lunarDate:"",location:"",animal:"",clock:"",LunarCal:[new TagLunarCal(27,5,3,43,1,0,0,1,0,0,1,1,0,1,1,0,1),new TagLunarCal(46,0,4,48,1,0,0,1,0,0,1,0,1,1,1,0,1),new TagLunarCal(35,0,5,53,1,1,0,0,1,0,0,1,0,1,1,0,1),new TagLunarCal(23,4,0,59,1,1,0,1,0,1,0,0,1,0,1,0,1),new TagLunarCal(42,0,1,4,1,1,0,1,0,1,0,0,1,0,1,0,1),new TagLunarCal(31,0,2,9,1,1,0,1,1,0,1,0,0,1,0,1,0),new TagLunarCal(21,2,3,14,0,1,0,1,1,0,1,0,1,0,1,0,1),new TagLunarCal(39,0,5,20,0,1,0,1,0,1,1,0,1,0,1,0,1),new TagLunarCal(28,7,6,25,1,0,1,0,1,0,1,0,1,1,0,1,1),new TagLunarCal(48,0,0,30,0,0,1,0,0,1,0,1,1,1,0,1,1),new TagLunarCal(37,0,1,35,1,0,0,1,0,0,1,0,1,1,0,1,1),new TagLunarCal(25,5,3,41,1,1,0,0,1,0,0,1,0,1,0,1,1),new TagLunarCal(44,0,4,46,1,0,1,0,1,0,0,1,0,1,0,1,1),new TagLunarCal(33,0,5,51,1,0,1,1,0,1,0,0,1,0,1,0,1),new TagLunarCal(22,4,6,56,1,0,1,1,0,1,0,1,0,1,0,1,0),new TagLunarCal(40,0,1,2,1,0,1,1,0,1,0,1,0,1,0,1,0),new TagLunarCal(30,9,2,7,0,1,0,1,0,1,0,1,1,0,1,0,1),new TagLunarCal(49,0,3,12,0,1,0,0,1,0,1,1,1,0,1,0,1),new TagLunarCal(38,0,4,17,1,0,1,0,0,1,0,1,1,0,1,1,0),new TagLunarCal(27,6,6,23,0,1,0,1,0,0,1,0,1,0,1,1,1),new TagLunarCal(46,0,0,28,0,1,0,1,0,0,1,0,1,0,1,1,0),new TagLunarCal(35,0,1,33,0,1,1,0,1,0,0,1,0,0,1,1,0),new TagLunarCal(24,4,2,38,0,1,1,1,0,1,0,0,1,0,1,0,1),new TagLunarCal(42,0,4,44,0,1,1,0,1,0,1,0,1,0,1,0,1),new TagLunarCal(31,0,5,49,1,0,1,0,1,1,0,1,0,1,0,1,0),new TagLunarCal(21,2,6,54,0,1,0,1,0,1,0,1,1,0,1,0,1),new TagLunarCal(40,0,0,59,0,1,0,0,1,0,1,1,0,1,1,0,1),new TagLunarCal(28,6,2,5,1,0,1,0,0,1,0,1,0,1,1,1,0),new TagLunarCal(47,0,3,10,1,0,1,0,0,1,0,0,1,1,1,0,1),new TagLunarCal(36,0,4,15,1,1,0,1,0,0,1,0,0,1,1,0,1),new TagLunarCal(25,5,5,20,1,1,1,0,1,0,0,1,0,0,1,1,0),new TagLunarCal(43,0,0,26,1,1,0,1,0,1,0,1,0,0,1,0,1),new TagLunarCal(32,0,1,31,1,1,0,1,1,0,1,0,1,0,1,0,0),new TagLunarCal(22,3,2,36,0,1,1,0,1,0,1,1,0,1,0,1,0)],SolarCal:[31,28,31,30,31,30,31,31,30,31,30,31],SolarDays:[0,31,59,90,120,151,181,212,243,273,304,334,365,396,0,31,60,91,121,152,182,213,244,274,305,335,366,397],AnimalIdx:["马","羊","猴","鸡","狗","猪","鼠","牛","虎","兔","龙","蛇"],LocationIdx:["南.","東.","北.","西."]}),mounted(){this.calConv()},methods:{getLeap:a=>a%400==0?1:a%100==0?0:a%4==0?1:0,calConv(){const a=new Date,n=a.getFullYear(),e=a.getMonth()+1,t=a.getDate();if(n<1998||n>2032)return void console.error("年份超出计算范围");let l=this.getLeap(n),r=e-1;if(t<1||t>[31,l?29:28,31,30,31,30,31,31,30,31,30,31][r])return void console.error("日期超出范围");let u=this.SolarDays[14*l+r]+t,o=n-1998,s=this.LunarCal[o],g=u+s.BaseKanChih,C=g%12;this.location=this.LocationIdx[g%4],this.animal=this.AnimalIdx[C],u<=s.BaseDays&&(o--,s=this.LunarCal[o]);let h=s.BaseDays;for(let a=0;a<s.MonthDays.length;a++){let n=h+s.MonthDays[a]+29;if(u<=n){this.lunarMonth=a+1,this.lunarDate=u-h;break}h=n}let i=s.Intercalation;0!=i&&this.lunarMonth>i&&(this.lunarMonth--,this.lunarMonth==i&&(this.lunarMonth=-i)),this.lunarMonth>12&&(this.lunarMonth-=12)},updateClock(){const a=new Date;let n=a.getHours(),e=a.getMinutes(),t=a.getSeconds();e=e<10?"0"+e:e,t=t<10?"0"+t:t,this.clock=n+":"+e+":"+t,setTimeout(this.updateClock,1e3)}}});

function getDomainQuery(url) {   
    var d = [];   
    var st = url.indexOf('//', 1);   
    var _domain = url.substring(st + 1, url.length);   
    var et = _domain.indexOf('/', 1);   
    d.push(_domain.substring(1, et));   
    d.push(_domain.substring(et + 1, url.length));    
    return d   
}   
    
function route() {   
    var eg = [];   
    eg.push(['baidu', 'wd']);   
    eg.push(['google', 'q']);   
    eg.push(['soso', 'w']);   
    eg.push(['yodao', 'q']);   
    eg.push(['bing', 'q']);   
    eg.push(['yahoo', 'q']);   
    eg.push(['sogou', 'query']);   
    eg.push(['gougou', 'search']);   
    eg.push(['360', 'q']);   
    
    var dq = getDomainQuery(document.referrer);   
        
    var keyword='';   
    var grep=null;   
    var str=null;   
  
    for(var el in eg){   
        var s = eg[el];   
        var DandQ=String(s).split(","); //字符分割  
        if (dq[0].indexOf(DandQ[0])>0){   
            eval("grep=/"+DandQ[1]+"\=.*\&/i;");   
            str = dq[1].match(grep);   
            keyword = str.toString().split("=")[1].split("&")[0];   
            keyword = decodeURIComponent(keyword);   
            return keyword;   
        }   
    }   
    
    return keyword;
} 

